package com.datechange.demo.service.impl;

import com.datechange.demo.dao.CmsPublicContentDao;
import com.datechange.demo.entity.CmsPublicContent;
import com.datechange.demo.service.CmsPublicContentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 内容(CmsPublicContent)表服务实现类
 *
 * @author makejava
 * @since 2020-12-09 10:46:01
 */
@Service("cmsPublicContentService")
public class CmsPublicContentServiceImpl implements CmsPublicContentService {
    @Resource
    private CmsPublicContentDao cmsPublicContentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param cpcId 主键
     * @return 实例对象
     */
    @Override
    public CmsPublicContent queryById(String cpcId) {
        return this.cmsPublicContentDao.queryById(cpcId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CmsPublicContent> queryAllByLimit(int offset, int limit) {
        return this.cmsPublicContentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param cmsPublicContent 实例对象
     * @return 实例对象
     */
    @Override
    public CmsPublicContent insert(CmsPublicContent cmsPublicContent) {
        this.cmsPublicContentDao.insert(cmsPublicContent);
        return cmsPublicContent;
    }

    /**
     * 修改数据
     *
     * @param cmsPublicContent 实例对象
     * @return 实例对象
     */
    @Override
    public CmsPublicContent update(CmsPublicContent cmsPublicContent) {
        this.cmsPublicContentDao.update(cmsPublicContent);
        return this.queryById(cmsPublicContent.getCpcId());
    }

    /**
     * 通过主键删除数据
     *
     * @param cpcId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String cpcId) {
        return this.cmsPublicContentDao.deleteById(cpcId) > 0;
    }

    @Override
    public List<CmsPublicContent> list(String pid,String ccId) {

        return cmsPublicContentDao.list(pid,ccId);
    }
}